package com.dq.controller.api.merchant.message;

import com.dq.exception.customException.AdminException;
import com.dq.vo.Vo;
import com.dq.domain.message.oneself.info.InstructionMessageReturn;
import com.dq.service.AllService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author luchangtong
 * @Date 2019/12/25 17:17
 */
@Api(description = "指令审核")
@RestController
@RequestMapping("/api/instruction/")
public class InstructionReturnController extends AllService {

    @PostMapping("/check/{id}/{bossStatus}")
    @ApiOperation("指令确认")
    public Vo check(@PathVariable Long id,@PathVariable InstructionMessageReturn.BossStatus bossStatus) throws AdminException{
        InstructionMessageReturn instructionMessageReturn = dao.get(InstructionMessageReturn.class,id);
        if(instructionMessageReturn == null){
            throw new AdminException("请重新选择指令");
        }
        instructionMessageReturn.setBossStatus(bossStatus);
        instructionMessageReturnRepository.save(instructionMessageReturn);
        return new Vo(HttpStatus.OK);
    }
}
